package org.yn.auth.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.yn.auth.domain.Permission;
import org.yn.auth.mapper.PermissionMapper;
import org.yn.auth.query.PermissionQuery;
import org.yn.auth.service.IPermissionService;
import org.yn.base.util.PageInfo;

import java.util.List;
@Service
public class PermissionServiceImpl implements IPermissionService {
    @Autowired
    PermissionMapper permissionMapper;

    @Override
    public void deleteAll() {
        permissionMapper.deleteAll();
    }

    /**
     * 分页查询
     *
     * @param permissionQuery
     * @return
     */
    @Override
    public PageInfo<Permission> queryPage(PermissionQuery permissionQuery) {

        Integer total =permissionMapper.countTotal(permissionQuery);
        if (total==0||total.equals(null)){
            return new PageInfo<Permission>();//返回一个空的
        }
        //查询分页数据
        List<Permission> list= permissionMapper.queryPage(permissionQuery);

        return new PageInfo<Permission>(total, list);
    }

    @Override
    public List<Permission> queryPermission() {
        return permissionMapper.queryPermission();
    }

}
